package com.hrp.controller;

import com.hrp.domain.Combox;
import com.hrp.domain.Jjfact;
import com.hrp.domain.ResponseData;
import com.hrp.domain.Tree;
import com.hrp.service.JjfactService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Administrator on 2018/8/15 0015.
 */
@RestController
@RequestMapping("jjfact")
public class JjfactController {

    @Autowired
    private JjfactService jjfactService;


    @RequestMapping("/getJjfactTree")
    public List<Tree> getJjfactTree(){
        return jjfactService.getAllJjfact();
    }

    @RequestMapping("/updateJjgsmb")
    public ResponseData updateJjgsmb(String gsmb, Integer jjzbid, String gsHtml){
        try{
            jjfactService.updateJjgsmb(gsmb,jjzbid,gsHtml);
            return ResponseData.ok();
        }catch (Exception e){
            return ResponseData.build(500,"保存失败");
        }
    }

    @RequestMapping("/getJjgsmb")
    public String getJjgsmb(Integer id){
        return jjfactService.getJjgsmb(id);
    }

    @RequestMapping("/getAllJJfact")
    public ResponseData getAllJJfact(){
        try{
            List<Jjfact> list = jjfactService.getAllJJfact();
            return ResponseData.build(200,"获取数据称工",list);
        }catch (Exception e){
            e.printStackTrace();
            return ResponseData.build(500,"数据获取失败");
        }
    }

    @RequestMapping("/getJjfactId")
    public ResponseData getJjfactId(){
        try{
            Integer id = jjfactService.getJjfactId();
            return ResponseData.build(200,"获取数据成功",id);
        }catch (Exception e){
            e.printStackTrace();
            return ResponseData.build(500,"数据获取失败");
        }
    }

    @RequestMapping("/saveJjfactData")
    public ResponseData saveJjfactData(Jjfact jjfact){
        try{
            jjfactService.saveJjfactData(jjfact);
            return ResponseData.ok();
        }catch (Exception e){
            e.printStackTrace();
            return ResponseData.build(500,"保存数据失败");
        }

    }


}
